<!DOCTYPE html>
  <html>
  <head>
      <meta charset="utf-8">
      <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
      <title>title</title>
      <link rel="stylesheet" type="text/css" href="../css/api.css"/>
      <link rel="stylesheet" type="text/css" href="../css/aui.css" />
      <style>
          body{

          }
      </style>
  </head>
  <body>
    <header class="aui-bar aui-bar-nav">注册页面</header>
    <div id="app">
    <form>
    <ul class="aui-list aui-form-list">
      <li class="aui-list-item">
          <div class="aui-list-item-inner">
              <div class="aui-list-item-label">
                  姓名
              </div>
              <div class="aui-list-item-input">
                  <input name = 'username' type="text" placeholder="Name">
              </div>
          </div>
      </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">
                        账号
                    </div>
                    <div class="aui-list-item-input">
                        <input name = 'userid' type="text" placeholder="输入id账号">
                    </div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">
                        密码
                    </div>
                    <div class="aui-list-item-input">
                        <input name = 'userps' type="password" placeholder="Password">
                    </div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">
                        重复密码
                    </div>
                    <div class="aui-list-item-input">
                        <input name = 'password2' type="password" placeholder="Password">
                    </div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">
                        类型
                    </div>
                    <div class="aui-list-item-input">
                        <label><input class="aui-radio" v-model="isTeacher" value="2" type="radio" name="usertype"> 教师</label>
                        <label><input class="aui-radio" v-model="isTeacher" value="1" type="radio" name="usertype"> 学生</label>
                    </div>
                </div>
            </li>
            <li v-show="isTeacher === '1'" class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">
                        你的老师
                    </div>
                    <div class="aui-list-item-input">

                        <select name="usertotea">
                          <option value="0">请选择你的老师..</option>
                            <option v-for="item in teacher" :value="item.userid">{{item.userid}}-{{item.username}}</option>

                        </select>
                    </div>
                </div>
            </li>


            <li class="aui-list-item">
                <div class="aui-list-item-inner aui-list-item-center aui-list-item-btn">
                    <div onclick = "zhuce();" class="aui-btn aui-btn-info aui-margin-r-5">提交</div>
                    <div onclick = "closet();" class="aui-btn aui-btn-danger aui-margin-l-5">取消</div>
                </div>
            </li>
        </ul>
        <form>
</div>

  </body>
  <script type="text/javascript" src="../script/api.js"></script>
  <script type="text/javascript" src="../script/vue.js"></script>
  <script type="text/javascript" src="../script/jquery-1.12.4.min.js"></script>
  <script type="text/javascript" src="../layer/layer.js"></script>
  <script type="text/javascript" src="../script/init.js" ></script>
  <script src="../script/vue.js"></script>
  <script type="text/javascript">
  closet = function () {
    api.closeWin()
  }
  var app = new Vue({
    el:'#app',
    data:{
      teacher :[],
      isTeacher: "1"

    },
    created:function() {
      this.getTeacher()
    },
    methods:{
      getTeacher () {
        $.ajax({
        url:bashUrl+'teacher',
        type:"get",
        data:{},
        timeout:3000,
        dataType:"json",
        success:(data)=>{
          this.teacher = data.users
        },
        error: function () {

          api.toast({msg:"请求超时或繁忙",duration : 2000})
        }
        });
      }
    }
  })

      function zhuce() {
        var formdata = $('form').serializeArray()
        if(formdata[2].value !== formdata[3].value){
          api.toast({msg:'两次密码不一致',duration : 2000})

        }else if (formdata[1].value === '' || formdata[2].value === '') {
          api.toast({msg:"账号或密码不能为空",duration : 2000})

        }else{
          $.post(bashUrl+'regist', $('form').serialize(),function(data){
            if(data.meg === '1'){
              api.toast({msg:"注册成功",duration : 2000})
              setTimeout(function () {
                api.closeWin()
              }, 1500);

            }else{
              api.toast({msg:"注册失败，服务器繁忙",duration : 2000})
            }
          })
        }


      //   api.ajax({
    	// 	url: 'http://192.168.137.1:8080/android_caiwu/toregist.action',
    	// 	method: 'get',
    	// 	timeout: 30,
    	// 	dataType: 'text',
    	// 	returnAll: false,
    	// 	data: {
    	// 		values: { //you参数
      //       username : 123,
      //       password:123
    	// 		},
    	// 	}
    	// }, function(ret, err) {
    	// 	if (ret) {
    	// 		alert(ret)
      //
    	// 	}else{
      //     alert(2)
      //   }
    	// })

      }

      apiready = function(){


      };
  </script>
  </html>
